


<%def name="_render_local(name, this)"><%
    getattr(self, name)(this)
%></%def>




<%def name="render_widget(this)"><%
    if this.render:
        path = request.get_template_file(this)
        ns = local.get_namespace(path)
        tdef = getattr(ns, this.template_name)
        tdef(this)
%></%def>




<%def name="render_children(this)"><%
    for item in this:
        self.render_widget(item)
%></%def>




<%def name="screen_frame(this)">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
    <title>${ this.title }</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="content-script-type" content="text/javascript">

    % for url in this.stylesheet_urls():
        <link href=${url} rel=stylesheet type=text/css>
    % endfor

    <!--[if lt IE 7]>
        <script>
        var IE7_PNG_SUFFIX = ".png";
        </script>
        <script src="${request.static_url('js/IE7.js')}"></script>
    <![endif]-->

</head><body>

    <form method=POST
          action=${this.context_location}
          accept-charset=${request.response.charset}
          id=${this.id}
          class="${this.css_class}"
          autocomplete=off>

    <% self.render_children(this) %>

    <input  type=hidden 
            id="${request.bind_key}"
            name="${request.bind_key}"
            value="">

    </form>

    <script>this.__started = (new Date) - ${ int(request.timer() * 1000) }</script>

    % for url in this.javascript_urls():
        <script src=${url}></script>
    % endfor

    <script>${this.install_script() | n}</script>

<!-- ${ "%.1f" % (request.timer()*1000) } ms -->
</%def>




<%def name="parent_link(this)">
    &laquo; ${self.link(this)}
</%def>




<%def name="bare_panel(this)">
    <div id=${this.id} class="${this.css_class}">
        <% self.render_children(this) %>
    </div>
</%def>




<%def name="content_panel(this)">
    <div id=${this.id} class="${this.css_class}">
        <div class=content>
            <% self.render_children(this) %>
        </div>
    </div>
</%def>



<%def name="action_panel(this)">
    <div id=${this.id} class="${this.css_class}">
    <div class=content>
        % for child in this:
            % if child.render:
                <div id="${child.id}_field"
                     class="action ${child.css_class}">
                    <% self.render_widget(child) %>
                </div>
            % endif
        % endfor
    </div>
    </div>
</%def>





<%def name="screen_title(this)">
    <h2>${ this.title }</h2>
</%def>




<%def name="link(this)">
    % if this.screen.modal:
        <span class="${ this.text_class or ''}">${ this.label }</span>
    % else:
        <a class="${this.link_class or ''}"
           href="${this.url}">${this.label}</a>
    % endif
</%def>




<%def name="text(this)">
    <span class="${ this.text_class or ''}">${ this.text }</span>
</%def>




<%def name="textblock(this)">
    <p class="${ this.text_class or ''}">${ this.text }</p>
</%def>




<%def name="link_list(this)">
    <ul>
    % for link in this:
        <li><% self.render_widget(link) %>
    % endfor
    </ul>
</%def>




<%def name="model_list(this)">
    <table class="${this.css_class}">
    % if this.show_header:
        <tr>
        % for x in this.iter_headers():
            <th>${x}</th>
        % endfor
        </tr>
    % endif

    % for i, row in this.iter_rows():
        <tr class="${ i and "nonfirst" or "first" } \
                   ${ i%2 and 'altodd' or 'alteven' } row${i}">
            % for j, cell in row:
                <td>
                    ${ self.render_widget(cell) }
                </td>
            % endfor
        </tr>
    % endfor
    </table>
</%def>




<%def name="string_view(this)">
    <span id=${this.id}>${this.formatted}</span>
</%def>




<%def name="text_view(this)">
    <span id=${this.id}>
        %for line in this.formatted.split('\n'):
            ${line}<br>
        % endfor
    </span>
</%def>




<%def name="string_edit(this)">
    <input  type=text 
            id=${this.id} 
            name=${this.name} 
            value="${this.simplified}">
</%def>




<%def name="string_mask_view(this)">
    <span class="string-mask-view"
        >${ "*" * len(this.formatted) }</span>
</%def>




<%def name="string_mask_edit(this)">
    <input  type=password 
            id=${this.id} 
            name=${this.name} 
            ## value="${this.simplified}"
        >
</%def>




<%def name="stamp_view(this)">
    ${ this.formatted }
</%def>




<%def name="date_view(this)">
    ${ self.string_view(this) }
</%def>




<%def name="date_edit(this)">
    <input  type=hidden 
            id="${this.id}_value"
            name="${this.name}"
            value="${this.simplified}">
    <input  type=text 
            id="${this.id}_date_input"
            class="date-input"
            value="${this.format_date()}">
</%def>




<%def name="time_view(this)">
    ${ self.string_view(this) }
</%def>




<%def name="time_edit(this)">
    <input  type=text 
            id=${this.id}
            name="${this.name}"
            class="time-input"
            value="${this.formatted}">
</%def>




<%def name="minutes_edit(this)">
    <input  type=text 
            id=${this.id}
            name="${this.name}"
            class="minutes-input"
            value="${this.simplified}">
</%def>




<%def name="local_datetime_view(this)">
    ${ self.string_view(this) }
</%def>




<%def name="local_datetime_edit(this)">
    ${ self.date_edit(this) }
    <input  type=text 
            id="${this.id}_time_input"
            class="time-input"
            value="${this.formatted_time}">
    <span class=timezone-indicator>${ this.formatted_tz }</span>
</%def>




<%def name="textbox_view(this)">
    ${ self.string_view(this) }
</%def>




<%def name="child_single_view(this)">
    ${ model_list(this) }
</%def>




<%def name="child_single_edit(this)">
    ${ child_list_edit(this) }
</%def>




<%def name="child_list_view(this)">
    ${ model_list(this) }
</%def>




<%def name="child_list_edit(this)">
    <% j = 0 %>
    <div id=${this.id}>
    <table class=model-list>
    % if this.show_header:
        <tr>
            % for x in this.iter_headers():
                <th>${x}</th>
            % endfor
            <th></th>
        </tr>
    % endif

    % for i, row, edit, delete in this.iter_rows():
        <tr class="${ i and 'nonfirst' or 'first' } \
                   ${ i%2 and 'altodd' or 'alteven'} \
                   ${ edit and 'editable' or ''} \
                   ${ delete and 'deletable' or ''} \
                   row${i}"
            bind=${edit}>

            % for j, label in row:
                <td>
                    ${self.render_widget(label)}
                </td>
            % endfor

            <td class=delete-column>
                <a class=delete-link bind=${delete}
                    ><img src=${request.static_url('img/trash.png')}></a>
            </td>
        </tr>
    % endfor
    </table>
    % if this.addable:
        <button id=${this.id}_add_button
                bind=${this.add_bind()}
                class=immediate-action
                style=overflow:visible
                >Add</button>
    % endif
    <p>
    </div>
</%def>




<%def name="child_inline_single_view(this)">
</%def>




<%def name="child_inline_single_edit(this)">
</%def>




<%def name="child_inline_list_view(this)">
</%def>




<%def name="child_inline_list_edit(this)">
</%def>




<%def name="textbox_edit(this)">
    <textarea   id=${this.id} 
                cols=${this.columns}
                rows=${this.rows}
                name=${this.name}
    >${ this.simplified }</textarea>
</%def>




<%def name="simple_list_view(this)">
    % if this.value:
        % for value in this.value:
            ${ value }<br>
        % endfor
    % else:
        (none)
    % endif
</%def>




<%def name="simple_list_edit(this)">
    <ul>
    <% i = -1 %>
    % for i, value in enumerate(this.field.get_simplified()):
        <li>
            <input  id=${this.id}_${i}
                    name=${this.name}-${i}
                    value="${value}">
        </li>
    % endfor
        <li>
            <input  id=${this.id}_${i+1}
                    name=${this.name}-${i+1}
                    value="(new)">
        </li>
    </ul>
</%def>




<%def name="simple_select_list(this)">
    <ul id=${this.id}
        class="${this.scrolling and 'scrolling' or ''}"
        % if this.scroll_height:
            style="height:${this.scroll_height}"
        % endif
        >
    % for id, value, label, selected in this.iter_options():
        <li>
            <label for=${id} class=checklabel>
                <input  id=${id}
                        class=checkbox
                        ${selected and 'checked=checked' or ''}
                        name=${this.name}
                        type=checkbox
                        value="${value}">
              ${ label }
            </label>
    % endfor
    </ul>
</%def>




<%def name="single_option_select_view(this)">
    ${ self.string_view(this) }
</%def>




<%def name="reference_view(this)">
    <span id=${this.id}>${ self.render_widget(this.link) }</span>
</%def>




<%def name="reference_list_view(this)">
    ${ model_list(this) }
</%def>




<%def name="radio_select(this)">
    <div id=${this.id}>
    % for id, value, label, selected in this.iter_options():
        <label for=${id} class=checklabel>
        <input  type=radio 
                id=${id}
                name=${this.name} 
                ${selected and 'checked=checked' or ''}
                value="${value}"
        >&nbsp;${label}</label>
        % if this.orient == 'vertical':
            <br>
        % endif
    % endfor
    </div>
</%def>




<%def name="boolean_edit(this)">
    ${ self.radio_select(this) }
</%def>




<%def name="single_option_select(this)">
    <select id=${this.id} name=${this.name}>
    % for id, value, label, selected in this.iter_options():
        <option id=${id} 
                ${selected and 'selected=selected' or ''}
                value="${value}">${label}</option>
    % endfor
    % if this.other_key:
        <option id=${id}_other_option 
                ${this.value == this.other_key and 'selected=selected' or ''}
                value="${this.other_key}">${this.other_label}</option>
    % endif
    </select>
    % if this.other_key:
        <br>
        <button id=${this.id}_select_other
                style=overflow:visible
        >${this.other_label}</button>
    % endif
</%def>




<%def name="message_button(this)">
    ${this.text}
</%def>




<%def name="toolbar_button(this)">
  <button
    disabled=disabled
    id="${this.id}"
    bind="${this.bind}"
    class="${this.button_class}" 
    style=overflow:visible
    >${this.label}</button>
</%def>




<%def name="toggle_button(this)">
  <input type=hidden id=${this.id}_hidden name=${this.name} value=${this.simplified}>
  <button
    ## disabled=disabled
    id=${this.id}_button
    class="toggle-button"
    style=overflow:visible
    >${this.value and this.label_on or this.label_off}</button>
</%def>




<%def name="navbuttons(this)">
   <button
     id=${this.id}_back
     class="navback"
     value=1
     % if this.bind_back:
         name=${this.request.bind_key}.${this.bind_back}
     % else:
         disabled=disabled
     % endif
    style=overflow:visible
     >${this.label_back}</button>
 
   <button
     id=${this.id}_forward
     class="navforward"
     value=1
     % if this.bind_forward:
         name=${this.request.bind_key}.${this.bind_forward}
     % else:
         disabled=disabled
     % endif
    style=overflow:visible
     >${this.label_forward}</button>

</%def>




<%def name="submit_button(this)">
  <button
    id=${this.id}
    class="${this.button_class}" 
    name=${request.bind_key + '.' + this.id}
    value=1
    style=overflow:visible
    >${this.label}</button>
</%def>




<%def name="filter_field(this)">
    <% self.render_children(this) %>
</%def>




<%def name="button_bar(this)">
    <table class=button-bar><tr>
    % for child in this:
        % if child.render:
            <td id="${child.id}_field"
                class="form-field-control ${child.css_class}"
                >
                <% self.render_widget(child) %>
            </td>
        % endif
    % endfor
    </tr></table>
    <div style=clear:both></div>
</%def>




<%def name="model_form(this)">
    <div id=${this.id} class="${this.css_class}">
    <% self.render_children(this) %>
    </div>
</%def>




<%def name="model_history(this, obj=None)">
    <div class="object-history">
        <table>
        % for i, e in enumerate((obj or this.model)._meta.events):
            <tr class="${ i%2 and 'altodd' or 'alteven'}">
                <td>${e.when}
                <td>${e.userid}
                <td>${e.action}
                <td valign=top>
                    % for x in e.attrs:
                        ${x.summary}<br>
                    % endfor
                    % if e.comment_text:
                        <span class=history-comment>${e.comment_text}</span>
                    % endif
                </td>
            </tr>
        % endfor
        </table>
    </div>
</%def>




<%def name="field_group(this)">
<table class="form-layout ${this.key and 'field-group-'+this.key}">

    <col class=form-error-hint>
    <col class=form-field-labels>
    <col class=form-field-values>

    % if this.header:
        <tr><th colspan=3 class=section-header>${this.header}</th></tr>
    % endif

    % for field in this.fields:
      <tr id=${field.key}_field
          class="form-field ${field.index and "nonfirst" or "first"} \
                  row${field.index} \
                  ${ field.widget.hidden and 'hide' or '' } \
                  ${ field.editable and 'editable' or 'readonly' } \
                  ${ field.editable and (field.required and 'required' or 'optional') or '' } \
                  ${ field.error and 'has-alert' or '' } \
                  ${ field.hint and 'has-hint' or '' } \
                  ${ field.index%2 and 'odd' or 'even' }">

        <td class=form-field-hint>
            <div id=${field.key}_hint class=icon></div>
            <div class=content>
                <div id=${field.key}_help class=hint-help>${field.hint and field.hint.replace('\n', '<br>') or '' | n}</div>
                <div id=${field.key}_error class=hint-error>${field.error}</div>
            </div>
        </td>

        <th class=form-field-label>${field.label}</th>

        <td id="${field.key}_input"
            class="form-field-control ${field.widget.css_class}">
        <% self.render_widget(field.widget) %>
        </td>
        
    </tr>
    % endfor

</table>
</%def>




